﻿using System;
using Fabrication.Tests.TestClasses;
using NUnit.Framework;

namespace Fabrication.Tests
{
    [TestFixture]
    public class time_rules
    {
        [Test]
        public void should_use_future_datetime()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<DateTime>>()
                .For(x => x.Value).UseFutureTime(TimeSpan.FromHours(30))
                .Generate();

            Assert.That(builtItem.Value, Is.InRange(DateTime.Now, DateTime.Now.AddHours(30)));
        }

        [Test]
        public void should_use_historic_datetime()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<DateTime>>()
                .For(x => x.Value).UseHistoricTime(TimeSpan.FromHours(2.5))
                .Generate();

            Assert.That(builtItem.Value, Is.InRange(DateTime.Now.AddHours((-2.5)), DateTime.Now));
        }

        [Test]
        public void should_use_timespan_range()
        {
            var builtItem = new FabricationScope().Setup<SinglePropertyClass<DateTime>>()
                .For(x => x.Value).UseRange(TimeSpan.FromMinutes(10))
                .Generate();

            Assert.That(builtItem.Value, Is.InRange(DateTime.Now.AddMinutes(-10), DateTime.Now.AddMinutes(10)));
        }
    }
}
